<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>我的订单</title>
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/tpshop.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/myaccount.css" />
    <script src="__STATIC__/js/jquery-1.11.3.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="__PUBLIC__/js/layer/layer.js" type="text/javascript"></script>
    <script type="text/javascript" src="__ROOT__/public/static/js/layer/laydate/laydate.js"></script>
</head>
<style>
    .navitems2 li .selected {color: #e23435;border-bottom-color: #e23435;}
</style>
<body class="bg-f5">
<include file="user/header"/>
<div class="home-index-middle">
    <div class="w1224">
        <div class="g-crumbs">
            <a href="{:U('Home/User/index')}">我的商城</a>
            <i class="litt-xyb"></i>
            <span>我的订单</span>
        </div>
        <div class="home-main">
            <include file="user/menu"/>
            <div class="ri-menu fr">
                <div class="menumain p">
                    <div class="navitems2 p" id="navitems5">
                        <ul>
                            <li>
                                <a href="{:U('Order/order_list')}" class="<if condition="$Request.param.type eq ''">selected</if>">全部订单</a>
                            </li>
                            <li>
                                <a href="{:U('Order/order_list',array('type'=>'WAITPAY'))}" class="<if condition="$Request.param.type eq 'WAITPAY'">selected</if>">待付款</a>
                            </li>
                            <li>
                                <a href="{:U('Order/order_list',array('type'=>'WAITSEND'))}" class="<if condition="$Request.param.type eq 'WAITSEND'">selected</if>">待发货</a>
                            </li>
                            <li>
                                <a href="{:U('Order/order_list',array('type'=>'WAITRECEIVE'))}" class="<if condition="$Request.param.type eq 'WAITRECEIVE'">selected</if>">待收货</a>
                            </li>
                            <li>
                                <a href="{:U('Order/comment',array('status'=>'0'))}" class="<if condition="$Request.param.type eq 'WAITCCOMMENT'">selected</if>">待评论</a>
                            </li>
                            <!--<li>-->
                            <!--<a href="javascript:void(0);" class="">预售订单</a>-->
                            <!--</li>-->
                        </ul>
                        <div class="wrap-line" <if condition="$Request.param.type eq 'WAITPAY'">style="width: 130px; left: 140px;"<elseif condition="$Request.param.type eq 'WAITSEND'"/>style="width: 130px; left: 270px;"<elseif condition="$Request.param.type eq 'WAITRECEIVE'"/>style="width: 130px; left: 400px;"<else/>style="width: 130px; left: 10px;"</if> >
                        <span style="left:15px;"></span>
                    </div>
                </div>
                <div class="menu_search p">
                    <form id="search_order" action="{:U('Order/order_list')}" method="get">
                        <input class="sea_ol" type="text" name="search_key" id="search_key" value="{$Request.param.search_key}"  placeholder="商品名称，订单编号" />
                        <input class="sea_et" type="submit" value="查询" style="cursor: pointer;"/>
                    <!--    <span class="coice">
                            更多筛选条件
                            <i class="jt-x"></i>
                        </span>
                        <div class="time-qjc">
                            下单时间：<input id="start_time" name="start_time" value="" style="width:150px;padding:7px 10px;border:1px solid #ccc;outline: none;"/>
                            <span>至</span>
                            <input id="end_time" name="end_time" style="width:150px;padding:7px 10px;border:1px solid #ccc;outline: none;" />
                            <div class="nearl-zj">
                                <ul>
                                    <li><a onclick="time_for_one_month();">最近一个月</a></li>
                                    <li><a onclick="time_for_three_month();">最近三个月</a></li>
                                    <li><a onclick="time_for_one_year();">最近一年</a></li>
                                </ul>
                            </div>
                            <div class="mu-btn">
                                <a onclick="check_search_order();" href="jsvascript:">查询</a>
                            </div>
                        </div>-->
                    </form>
                </div>
                <div class="orderbook-list">
                    <div class="book-tit">
                        <ul>
                            <li class="sx1">商品信息</i></li>
                            <li class="sx2">单价</li>
                            <li class="sx3">数量</li>
                            <li class="sx4">订单总金额</li>
                            <li class="sx5 s5clic">订单状态<i class="jt-x"></i></li>
                            <li class="sx6">操作</li>
                        </ul>
                    </div>
                    <div class="hid-derei">
                        <ul>
                            <li><a href="{:U('Order/order_list')}">全部订单</a></li>
                            <li><a href="{:U('Order/order_list',array('type'=>'WAITPAY'))}">待付款</a></li>
                            <li><a href="{:U('Order/order_list',array('type'=>'WAITSEND'))}">待发货</a></li>
                            <li><a href="{:U('Order/order_list',array('type'=>'WAITRECEIVE'))}">待收货</a></li>
                            <li><a href="{:U('Order/comment',array('status'=>'0'))}">待评论</a></li>
                            <li><a href="{:U('Order/order_list',array('type'=>'FINISH'))}">已完成</a></li>
				    		<li><a href="{:U('Order/order_list',array('type'=>'CANCEL'))}">已取消</a></li>
                            <!--<li><a href="">预售订单</a></li>-->
                        </ul>
                    </div>
                </div>
                <div class="order-alone-li lastset_cm">
                    <empty name="lists">
                        <div class="car-none-pl">
                            <i class="account-acco1"></i>您还没有订单，<a href="/">快去逛逛吧~</a>
                        </div>
                        <else/>
                        <volist name="lists" id="list">
                            <table width="100%" border="" cellspacing="" cellpadding="">
                                <tr class="time_or">
                                    <td colspan="6">
                                        <div class="fl_ttmm">
                                            <span class="time-num">下单时间{$list['cancel_info']}：<em class="num">{$list.add_time|date='Y-m-d H:i:s',###}</em></span>
                                            <span class="time-num">订单编号：<em class="num">{$list.order_sn}</em></span>
                                            <!--<span class="time-num">卖家：<a href="tencent://message/?uin={$store_list[$list[store_id]][store_qq]}&Site=TPshop商城&Menu=yes"><em class="num">{$store_list[$list[store_id]][store_name]}<i class="ear"></i></em></a></span>-->
                                            <div class="paysoon">
                                                <if condition="$list.pay_btn eq 1">
                                                    <a class="ps_lj" href="{:U('Home/Cart/cart4',array('order_id'=>$list[order_id]))}"  target="_blank">立即支付</a>
                                                </if>
                                                <if condition="$list['cancel_info'] eq 1">
                                                     <a class="consoorder" href="{:U('Order/cancel_order_info',array('order_id'=>$list[order_id]))}">取消详情</a>
                                                </if>

                                                <if condition="$list.receive_btn eq 1">
                                                    <a class="ps_lj" href="javascript:;" onclick="order_confirm({$list.order_id});">确认收货</a></if>
                                                <if condition="$list.cancel_btn eq 1">
                                                	<if condition="$list[pay_status] eq 0">
                                                    <a class="consoorder" href="javascript:void(0);" onClick="cancel_order({$list.order_id})" >取消订单</a>
                                                <else/>
                                                	<a class="consoorder" href="javascript:void(0);" data-url="{:U('Home/Order/refund_order',['order_id'=>$list.order_id])}" onClick="refund_order(this)" >取消订单</a>
                                                	</if>
                                                <else/>
                                                    <!--<div class="dele" onclick="verConfirm('确认删除该订单?','{:U('Home/Order/del_order',array('order_id'=>$list['order_id'], 'type'=>$Request.param.type))}')"></div>-->
                                                </if>
                                                <!--<div class="dele"></div>-->
                                            </div>
                                        </div>
                                        <div class="fr_ttmm"></div>
                                    </td>
                                </tr>
                                <volist name="list.goods_list" id="goods" key="k">
                                    <if condition="$k eq 1">
                                        <tr class="conten_or">
                                            <td class="sx1">
                                                <div class="shop-if-dif">
                                                    <div class="shop-difimg">
                                                        <img src="{$goods.goods_id|goods_thum_images=60,60}" width="60" height="60" />
                                                    </div>
                                                    <div class="shop_name">
                                                        <a href="{:U('Home/Goods/goodsInfo',array('id'=>$goods['goods_id']))}">
                                                            {$goods.goods_name}
                                                        </a>
                                                        <p>{$goods.spec_key_name}</p>
                                                    </div>
                                                </div>
                                            </td>
                                            <td class="sx2"><span>￥</span><span>{$goods.member_goods_price}</span></td>
                                            <td class="sx3">
                                                <span>x{$goods.goods_num}</span>
                                                <if condition="$goods[is_send] gt 1">
                                                    <a class="applyafts">已申请售后</a>
                            					<else />
	                            					<if condition="($list[return_btn] eq 1) and ($list[shipping_status] eq 1)">
	                                                    <a href="{:U('Home/Order/return_goods',array('rec_id'=>$goods['rec_id']))}" class="applyafts">申请售后</a>
	                                                </if>
                                                </if>
                                            </td>
                                            <td class="sx4" rowspan="{$list.goods_list|count}">
                                                <div class="pric_rhz">
                                                    <p class="d_pri"><span>￥</span><span>{$list.total_amount}</span></p>
                                                    <p class="d_yzo">
                                                        <spna>含运费：</spna>
                                                        <span>{$list.shipping_price}</span></p>
                                                    <p class="d_yzo"><a href="javascript:void(0);">{$list.pay_name}</a></p>
                                                </div>
                                            </td>
                                            <td class="sx5" rowspan="{$list.goods_list|count}">
                                                <div class="detail_or">
                                                    <p class="d_yzo">
                                                        {$list['order_status_desc']}
                                                    </p>
                                                    <p>
                                                        <if condition="$list[prom_type] eq 5">
                                                            <a href="{:U('Order/virtual_order',array('order_id'=>$list['order_id']))}">查看详情</a>
                                                        <else/>
                                                            <a href="{:U('Order/order_detail',array('id'=>$list['order_id']))}">查看详情</a>
                                                        </if>
                                                    </p>
                                                </div>
                                            </td>
                                            <td class="sx6" rowspan="{$list.goods_list|count}">
                                                <div class="rbac">
                                                    <p class=""><a class="buy_order" data-order-id="{$list.order_id}" href="javascript:;">再次购买</a></p>
                                                    <if condition="($list[comment_btn] eq 1) and ($goods[is_comment] eq 0)">
                                                        <p class="inspect">
                                                            <a href="{:U('Home/Order/comment',array('status'=>0))}">评价</a>
                                                        </p>
                                                    </if>
                                                </div>
                                            </td>
                                        </tr>
                                    <else />
                                        <tr class="conten_or">
                                            <td class="sx1">
                                                <div class="shop-if-dif">
                                                    <div class="shop-difimg">
                                                        <img src="{$goods.goods_id|goods_thum_images=60,60}" width="60" height="60"/>
                                                    </div>
                                                    <div class="shop_name">
                                                        <a href="{:U('Home/Goods/goodsInfo',array('id'=>$goods['goods_id']))}">
                                                            {$goods.goods_name}
                                                        </a>
                                                        <p>{$goods.spec_key_name}</p>
                                                    </div>
                                                </div>
                                            </td>
                                            <td class="sx2"><span>￥</span><span>{$goods.member_goods_price}</span></td>
                                            <td class="sx3">
                                                <span>x{$goods.goods_num}</span>
                                                <if condition="($list[return_btn] eq 1) and ($goods[is_send] lt 2)">
                                                    <a href="{:U('Home/Order/return_goods',array('rec_id'=>$goods['rec_id']))}" class="applyafts">申请售后</a>
                                                </if>
                                                <if condition="$goods[is_send] gt 1">
                                                    <a class="applyafts">已申请售后</a>
                                                </if>
                                            </td>
                                        </tr>
                                    </if>
                                </volist>
                            </table>
                        </volist>
                    </empty>
                </div>
            </div>
            <div class="operating fixed" id="bottom">
                <div class="fn_page clearfix">
                    {$page}
                </div>
            </div>
        </div>
    </div>
</div>
</div>
<!--footer-s-->
<div class="footer p">
    <include file="public/footer" />
</div>
<!--footer-e-->
<script type="text/javascript">
    $(function(){
        $('.s5clic').click(function(){
            $('.hid-derei').slideToggle(400);
            $(this).animate({opacity:"1"},200,function(){
                $(this).toggleClass('sxbb')
            })
        })
    })
    //取消订单
    function cancel_order(id){
        layer.confirm('确定取消订单?', {
                btn: ['确定','取消'] //按钮
            }, function(){
            $.ajax({
                url:"{:U('Home/Order/cancel_order')}",
                type:'POST',
                dataType:'JSON',
                data:{id:id},
                success:function(data){
                    if(data.status == 1){
                        layer.alert(data.msg, {icon: 1},function(){
                            location.href ='';
                        })
                    }else{
                        layer.alert(data.msg, {icon: 2});
                    }
                },
                error : function() {
                    layer.alert('网络失败，请刷新页面后重试', {icon: 2});
                }
            });
            }, function(index){
                layer.close(index);
            }
        );
    }

    function jump()
    {
        var max_page = "{$page_array.total_page}";
        var jump_page = $('#jump_page').val();
        if(jump_page>0 && jump_page<=max_page){
            location.href = "<?php echo urldecode(U('Home/Order/order_list',$get_no_p,''));?>"+"/p/"+$('#jump_page').val();
        }else{
            layer.alert('请输入正确的页数', {icon: 2});
        }
    }
    //确定收货
    function order_confirm(order_id){
        layer.confirm("你确定收到货了吗?",{
            btn:['确定','取消']
        },function(){
            $.ajax({
                type : 'post',
                url : '/index.php?m=Home&c=Order&a=order_confirm',
                data:{order_id:order_id},
                dataType : 'json',
                success : function(data){
                    if(data.status == 1){
                        layer.alert(data.msg, {icon: 1},function () {
                            window.location.href = data.url;
                        });
                    }else{
                        layer.alert(data.msg,{icon:2});
                    }
                },
                error : function(XMLHttpRequest, textStatus, errorThrown) {
                    layer.alert('网络失败，请刷新页面后重试', {icon: 2});
                }
            })
        }, function(index){
            layer.close(index);
        });
    }
    
	function refund_order(obj){
		layer.open({
			type: 2,
			title: '<b>订单取消申请</b>',
			skin: 'layui-layer-rim',
			shadeClose: true,
			shade: 0.5,
			area: ['600px', '500px'],
			content: $(obj).attr('data-url'),
		});
	}
    $(document).on('click', '.buy_order', function() {
        var order_id = $(this).data('order-id');
        $.ajax({
            type : "post",
            url : "{:U('Home/Order/oneMore')}",
            data:{order_id:order_id},
            dataType : 'json',
            success : function(data){
                var err_html = '';
                if(data.status == 1){
                    if(data.result.error_list.length == 0){
                        window.location.href = "{:U('Cart/index')}";
                    }else{
                        err_html = '以下商品加入购物车失败:<br/>';
                        $.each(data.result, function (n, value) {
                            err_html += value + '<br/>';
                        });
                        layer.open({
                            title:'加入购物车',
                            content: err_html,
                            btn: ['前往购物车', '取消'],
                            yes: function(index, layero){
                                window.location.href = "{:U('Cart/index')}";
                            },
                            btn2: function(index, layero){
                                layer.closeAll();
                            },
                            cancel: function(){
                                layer.closeAll();
                            }
                        });
                    }
                }else{
                    if(data.result.url != ''){
                        window.location.href = data.result.url;
                        return;
                    }
                    err_html = data.msg+':<br/>';
                    $.each(data.result.error_list, function (n, value) {
                        err_html += value + '<br/>';
                    });
                    layer.open({icon: 2, content: err_html});
                }
            }
        })
    })
</script>
</body>
</html>